﻿@model ProductReviewOverviewModel
@using System.Globalization
@using Nop.Web.Models.Catalog;
@{
    int ratingPercent = 0;
    if (Model.TotalReviews != 0)
    {
        ratingPercent = ((Model.RatingSum * 100) / Model.TotalReviews) / 5;
    }
}
@if (Model.AllowCustomerReviews)
{
    <div id="scroll-rating-reviews" class="product-reviews-overview-tab-box box-content" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <span class="floor-number">7</span>
        <div class="title">
            <span>Rating &amp; Reviews</span>
            <div class="rating">
                <div style="width: @(ratingPercent)%">
                </div>
            </div>
        </div>
        @if (Model.TotalReviews > 0)
        {
            <div class="product-review-links clearfix">
                <a href="@Url.RouteUrl("ProductReviews", new { productId = Model.ProductId })">
                    @Model.TotalReviews
                    @T("Reviews.Overview.Reviews")
                </a> <span class="separator">|</span> <a href="@Url.RouteUrl("ProductReviews", new { productId = Model.ProductId })">@T("Reviews.Overview.AddNew")</a>
            </div>
            @*hidden microdata info*@
            decimal ratingValue = ratingPercent / (decimal)20;
            <span itemprop="ratingValue" style="display: none;">@ratingValue.ToString("0.0", new CultureInfo("en-US"))</span>
            <span itemprop="reviewCount" style="display: none;">@Model.TotalReviews</span>
        }
        else
        {
            <div class="product-no-reviews">
                <a href="@Url.RouteUrl("ProductReviews", new { productId = Model.ProductId })">@T("Reviews.Overview.First")</a>
            </div>
        }
    </div>
}